package org.objectsearch.web.tools;

import java.util.Properties;

import org.w3c.dom.Document;

/**
 * @author Carlos
 * 
 */
public class ObjectXmlConfigurationEnviroment {

	private Properties objectMappingProperties;

	private Properties applicationProperties;

	private boolean debug = false;

	private Document objectMappings;

	private String connectionClass;

	private String enviromentPath;

	private static ObjectXmlConfigurationEnviroment instance = null;

	/**
	 * regresa la instancia del singleton.
	 * 
	 * @return singleton de el entorno de configuracion.
	 */
	public static ObjectXmlConfigurationEnviroment getInstance() {
		if (instance == null) {
			instance = new ObjectXmlConfigurationEnviroment();
		}
		return instance;
	}

	private ObjectXmlConfigurationEnviroment() {
	}

	/**
	 * @param objectMappingProperties
	 */
	public void setObjectMappingProperties(Properties objectMappingProperties) {
		this.objectMappingProperties = objectMappingProperties;
	}

	/**
	 * propiedades del mapeo.
	 * 
	 * @return propiedades del mapeo.
	 */
	public Properties getObjectMappingProperties() {
		return objectMappingProperties;
	}

	/**
	 * path del entorno.
	 * 
	 * @param enviromentPath
	 *            path del entorno.
	 */
	public void setEnviromentPath(String enviromentPath) {
		this.enviromentPath = enviromentPath;
	}

	/**
	 * path del entorno.
	 * 
	 * @return path del entorno.
	 */
	public String getEnviromentPath() {
		return enviromentPath;
	}

	/**
	 * @param applicationProperties
	 */
	public void setApplicationProperties(Properties applicationProperties) {
		this.applicationProperties = applicationProperties;
		String sDebug = applicationProperties.getProperty("application.debug");
		if (sDebug != null && sDebug.equals("true")) {
			setDebug(true);
		}
	}

	/**
	 * propiedades de la aplicacion.
	 * 
	 * @return propiedades de la aplicacion.
	 */
	public Properties getApplicationProperties() {
		return applicationProperties;
	}

	/**
	 * @param objectMappings
	 */
	public void setObjectMappings(Document objectMappings) {
		this.objectMappings = objectMappings;
	}

	/**
	 * mapeo de los objetos.
	 * 
	 * @return mapeo de los objetos.
	 */
	public Document getObjectMappings() {
		return objectMappings;
	}

	/**
	 * debug.
	 * 
	 * @param debug
	 *            debug.
	 */
	public void setDebug(boolean debug) {
		this.debug = debug;
	}

	/**
	 * debug.
	 * 
	 * @return debug.
	 */
	public boolean isDebug() {
		return debug;
	}

	/**
	 * @param connectionClass
	 */
	public void setConnectionClass(String connectionClass) {
		this.connectionClass = connectionClass;
	}

	/**
	 * clase de conexion.
	 * 
	 * @return clase de conexion.
	 */
	public String getConnectionClass() {
		return connectionClass;
	}

}